package com.smarthome.web.property.controller.system;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.smarthome.core.dictionary.AccountLogTypeService;
import com.smarthome.domain.bean.ShAccountLogType;
import com.smarthome.domain.common.Result;
import com.smarthome.domain.vo.boss.DataGrid;
import com.smarthome.domain.vo.boss.PageHelper;

@Controller
@RequestMapping(value="/accountLogType")
public class AccountLogTypeController {
	
	@Resource
	private AccountLogTypeService acountLogTypeService;
	
	@RequestMapping("/dataGrid")
	@ResponseBody
	public DataGrid dataGrid(ShAccountLogType queryLogType,PageHelper page){
		
		return acountLogTypeService.queryDatagrid(queryLogType, page);
	}
	
	@RequestMapping("/addPage")
	public String addPage(HttpServletRequest req){
		return "/system/dictionary/accountLogTypeAdd";
	}
	
	@RequestMapping("/add")
	@ResponseBody
	public Result add(ShAccountLogType logType){
		acountLogTypeService.add(logType);
		return Result.success("添加成功！");
	}
	
	@RequestMapping("/editPage")
	public String editPage(HttpServletRequest req,Long id){
		ShAccountLogType logType=acountLogTypeService.queryAccountLogTypeById(id);
		req.setAttribute("logType", logType);
		return "/system/dictionary/accountLogTypeEdit";
	}
	
	@RequestMapping("/edit")
	@ResponseBody
	public Result edit(ShAccountLogType logType){
		acountLogTypeService.edit(logType);
		return Result.success("更改成功！");
	}
	
	@RequestMapping("/delete")
	@ResponseBody
	public Result delete(Long id){
		acountLogTypeService.delete(id);
		return Result.success("删除成功！");
	}
}
